package com.yanu.meat.service.impl;

import com.yanu.meat.entity.SlaughterMeatSold;
import com.yanu.meat.dao.SlaughterMeatSoldDao;
import com.yanu.meat.service.SlaughterMeatSoldService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (SlaughterMeatSold)表服务实现类
 *
 * @author makejava
 * @since 2021-06-23 12:27:49
 */
@Service("slaughterMeatSoldService")
public class SlaughterMeatSoldServiceImpl implements SlaughterMeatSoldService {
    @Resource
    private SlaughterMeatSoldDao slaughterMeatSoldDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public SlaughterMeatSold queryById(Integer id) {
        return this.slaughterMeatSoldDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<SlaughterMeatSold> queryAllByLimit(int offset, int limit) {
        return this.slaughterMeatSoldDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param slaughterMeatSold 实例对象
     * @return 实例对象
     */
    @Override
    public SlaughterMeatSold insert(SlaughterMeatSold slaughterMeatSold) {
        this.slaughterMeatSoldDao.insert(slaughterMeatSold);
        return slaughterMeatSold;
    }

    /**
     * 修改数据
     *
     * @param slaughterMeatSold 实例对象
     * @return 实例对象
     */
    @Override
    public SlaughterMeatSold update(SlaughterMeatSold slaughterMeatSold) {
        this.slaughterMeatSoldDao.update(slaughterMeatSold);
        return this.queryById(slaughterMeatSold.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.slaughterMeatSoldDao.deleteById(id) > 0;
    }
}
